package 'tidyverse' successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\Hulwa\AppData\Local\Temp\Rtmpam05MD\downloaded_packages
package 'funModeling' successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\Hulwa\AppData\Local\Temp\Rtmpam05MD\downloaded_packages
1.2 Importing Geospatial Data
In this in-class data, two geospatial datasets will beused, they are:
geo_export
nga_ADM2
1.2.1 Importing Geospatial Data
First, we are going to import the water point geospatial data (i.e. geo_export) by using the code chunk below.
st_read() of sf package is used to import geo_export shapefile into R environment and save the imported geospatial data into simple feature data table.
filter() of dplyr package is used to extract water point records of Nigeria.
Next, write_rds() of readr package is used to save the extracted sf data table (i.e. wp) into an output file in rds data format. The output file is called wp_nga.rds and it is saved in geodata sub-folder.
write_rds(wp, "data/wp_nga.rds")
1.2.2 Import Nigeria LGA Boundary data
Now, we are going to import the LGA boundary data into R environment by using the code chunk below.
nga <-st_read(dsn ="data",layer ="geoBoundaries-NGA-ADM2",crs =4326)
Thing to learn from the code chunk above.
st_read() of sf package is used to import nga_admbnda_adm2_osgof_20190417 shapefile into R environment and save the imported geospatial data into simple feature data table.
1.3 Data Wrangling
1.3.1 Recoding NA values into string
In the code chunk below, replace_na() is used to recode all the NA values in status_cle field into Unknown.
In the code chunk below, freq() of funModeling package is used to display the distribution of status_cle field in wp_nga.
freq(data=wp_nga, input ='status_cle')
The above bar chart provide a brief understanding that the percentage of water-points that are functional in Nigeria is slightly less than 50%. It is crucial thus to dive deeper to determine if there are significant pattern in areas that do not have functional water-points and if the neighbouring areas can support those areas that face scarcity in water supply.
Observe that there are two categories with similar names (i.e. ‘Non-functional due to dry season’ and ‘Non functional due to dry season’, we will standardise this by shanging that later to ‘Non-functional due to dry season’.
1.4 Extracting Water Point Data
In this section, we will extract the water point records by using classes in status_cle field.
1.4.1 Extracting functional water point
In the code chunk below, filter() of dplyr is used to select functional water points.
wpt_functional <- wp_nga %>%filter(status_cle %in%c("Functional", "Functional but not in use","Functional but needs repair"))
freq(data = wpt_functional,input ="status_cle")
1.4.2 Extracting non-functional water point
In the code chunk below, filter() of dplyr is used to select non-functional water points.
wpt_nonfunctional <- wp_nga %>%filter(status_cle %in%c("Abandoned/Decommissioned", "Abandoned","Non-Functional","Non functional due to dry season","Non-Functional due to dry season"))
freq(data=wpt_nonfunctional, input ='status_cle')
1.4.3 Extracting water point with Unknown class
In the code chunk below, filter() of dplyr is used to select water points with unknown status.
Based on the above chart, we observe that in terms of functional water-points the north-west zone has the most functional water-points the number of non-functional water-points seems to be scattered all over in Nigeria.
It is interesting to note that while the district Ifelodun has a relatively higher number of functional waterpoints, it also has the highest number of non-functional waterpoints.
In terms of unknown waterpoint statuses it it mostly populated in the north-central zone of Nigeria.
For future work to consider demarcate the different regions in Nigeria as outline below to understand better if certain region faced water shortage more severely than other regions.